home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-07-03 | 2.1 KB | 64 lines | [TEXT/R*ch] |
- (* test/vector.sml -- some test cases for Vector
- PS 1994-12-10, 1995-06-14 *)
-
- use "auxil.sml";
-
- local
- open Vector;
- infix 9 sub;
- in
-
- val a = fromList [0,1,2,3,4,5,6];
- val b = fromList [44,55,66];
- val c = fromList [0,1,2,3,4,5,6];
-
- val test1 = check'(fn _ => a<>b);
- val test2 = check'(fn _ => a=c);
-
- val d = tabulate(100, fn i => i mod 7);
-
- val test3 = check'(fn _ => d sub 27 = 6);
-
- val test4a = (tabulate(maxLen+1, fn i => i) seq "WRONG")
- handle Size => "OK" | _ => "WRONG";
-
- val test4b = (tabulate(~1, fn i => i) seq "WRONG")
- handle Size => "OK" | _ => "WRONG";
-
- val test4c = check'(fn _ => length (tabulate(0, fn i => i div 0)) = 0);
-
- val test5 = check'(fn _ => length (fromList []) = 0 andalso length a = 7);
-
- val test6a = (c sub ~1 seq "WRONG") handle Subscript => "OK" | _ => "WRONG";
- val test6b = (c sub 7 seq "WRONG") handle Subscript => "OK" | _ => "WRONG";
- val test6c = check'(fn _ => c sub 0 = 0);
-
- val e = concat [d, b, d];
-
- val test7 = check'(fn _ => length e = 203);
-
- val test8 = check'(fn _ => length (concat []) = 0);
-
- val f = extract (e, 100, SOME 3);
-
- val test9 = check'(fn _ => f = b);
-
- val test9a = check'(fn _ => e = extract(e, 0, SOME (length e))
- andalso e = extract(e, 0, NONE));
- val test9b = check'(fn _ => fromList [] = extract(e, 100, SOME 0));
- val test9c = (extract(e, ~1, SOME (length e)) seq "WRONG")
- handle Subscript => "OK" | _ => "WRONG"
- val test9d = (extract(e, length e + 1, SOME 0) seq "WRONG")
- handle Subscript => "OK" | _ => "WRONG"
- val test9e = (extract(e, 0, SOME (length e+1)) seq "WRONG")
- handle Subscript => "OK" | _ => "WRONG"
- val test9f = (extract(e, 20, SOME ~1) seq "WRONG")
- handle Subscript => "OK" | _ => "WRONG"
- val test9g = (extract(e, ~1, NONE) seq "WRONG")
- handle Subscript => "OK" | _ => "WRONG"
- val test9h = (extract(e, length e + 1, NONE) seq "WRONG")
- handle Subscript => "OK" | _ => "WRONG"
- val test9i = check'(fn _ => fromList [] = extract(e, length e, SOME 0)
- andalso fromList [] = extract(e, length e, NONE));
- end;
-